package com.drink.yan.web.rest;

import com.drink.yan.intf.entity.YanRequirement;
import com.drink.yan.intf.entity.YanTask;
import com.drink.yan.intf.entity.YanTaskDeal;
import com.drink.yan.intf.vo.RequirementVo;
import com.drink.yan.intf.vo.TaskVo;
import com.drink.yan.intf.vo.YanTaskDealVo;
import com.drink.yan.svc.service.YanRequirementService;
import com.drink.yan.svc.service.YanTaskService;
import com.drink.yan.web.rest.req.cmd.ApproveTaskCmd;
import com.drink.yan.web.rest.req.cmd.CancelTaskCmd;
import com.drink.yan.web.rest.req.cmd.DealRequireCmd;
import com.drink.yan.web.rest.req.qry.PageRequireQry;
import com.drink.yan.web.rest.req.qry.PageTaskQry;
import com.meta.act.app.service.ISysNoticeService;
import com.meta.framework.common.core.controller.BaseController;
import com.meta.framework.common.core.page.TableResponseVo;
import com.meta.framework.common.utils.SecurityUtils;
import com.meta.framework.core.ResponseVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * java类简单作用描述
 *
 * @Title:
 * @Package: com.drink.yan.web.rest.app.
 * @Author: M.simple
 * @Remark: The modified content
 * @CreateDate: 2023/11/23 14:58
 * @Version: v2.0
 */
@RestController
@RequestMapping("/require")
public class RequirementRest extends BaseController {

    private ISysNoticeService noticeService;

    @Resource
    private YanRequirementService yanRequirementService;

    @ApiOperation(value = "获取需求", notes = "获取任务", tags = {"PC"})
    @GetMapping("/page")
    public TableResponseVo<List<RequirementVo>> listRequire(PageRequireQry qry){
        startPage();
        if (qry.isUserAuthFilter()) {
            qry.setCurrentUserId(SecurityUtils.getUserId());
        }
        List<RequirementVo> list = yanRequirementService.listRequire(qry);

        return getResponseVoTable(list);
    }

    @ApiOperation(value = "任务详情", notes = "任务详情", tags = {"PC"})
    @GetMapping("/detail/{requireNo}")
    public ResponseVo<RequirementVo> detail(@PathVariable Long requireNo){
        RequirementVo yanTask = yanRequirementService.getDetail(requireNo);

        return ResponseVo.success(yanTask);
    }

    @ApiOperation(value = "保存需求", notes = "保存需求", tags = {"PC"})
    @PostMapping("/save")
    public ResponseVo<YanRequirement> save(@RequestBody YanRequirement cmd){
        YanRequirement yanTask = yanRequirementService.saveRequire(cmd);

        return ResponseVo.success(yanTask);
    }

    @ApiOperation(value = "需求处理", notes = "需求处理", tags = {"PC"})
    @PostMapping("/deal")
    public ResponseVo<YanRequirement> dealSucc(@RequestBody DealRequireCmd cmd){
        YanRequirement yanTask = yanRequirementService.dealSucc(cmd);

        return ResponseVo.success(yanTask);
    }

    @ApiOperation(value = "需求完成", notes = "需求完成", tags = {"PC"})
    @PostMapping("/complete")
    public ResponseVo<YanTaskDeal> completeSucc(@RequestBody DealRequireCmd cmd){
        YanRequirement yanTask = yanRequirementService.completeSucc(cmd);

        return ResponseVo.success(yanTask);
    }

}
